#include <iostream>
#include <cmath>
using namespace std;
#define qia(i,a,b) for(int i=(a);i<=(b);++i)
#define gua(i,a,b) for(int i=(a);i*i<=(b);++i)
int n,ans;
int num[2005];
int f[2005];
bool b[2005];
int rua(int a,int b){
	int ret=1;
	gua(i,2,min(a,b)){
		while(!(a%i)&&!(b%i)){
			ret*=i;
			a/=i;b/=i;
		}
		while(!(a%i))a/=i;
		while(!(b%i))b/=i;
	}
	if(!(a%b))ret*=b;
	else if(!(b%a))ret*=a;
	return ret;
}
int main(){
	cin>>n;
	cin>>num[1];
	qia(i,2,n){
		cin>>num[i];
		f[i-1]=rua(num[i],num[i-1]);
		if(f[i-1]==min(num[i],num[i-1]))b[i-1]=1;
	}
	qia(i,1,n-1)
		if(b[i]){
			int m1=i-1,m2=i+1,len=2;
			while(m1>0&&!(f[m1]%f[i]))len++,m1--;
			while(m2<n&&!(f[m2]%f[i]))len++,m2++;
			qia(i,m1,m2)b[i]=0;
			ans=max(ans,len);
		}
	cout<<ans<<endl;
	return 0;
}
